package String;

/**
 * String支持的正则表达式方法二:
 * String replaceAll(String regex,String replacement)
 * 将当前字符串中满足正则表达式regex的部分替换为指定字符串replacement
 */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        String line = "abc123def456ghi";
        //将数字部分替换为#NUMBER#
        line = line.replaceAll("[0-9]+","#NUMBER#");
        System.out.println(line);

        //和谐用语
        String regex = "(gun|sb|fuck|sha)";
        String message = "你sb,gun吧!";
        message = message.replaceAll(regex,"***");
        System.out.println(message);
    }
}















